<template>
	<view>
		<view class="flex-ju-c">
			<image class="wh260-260 ra260 mt50" src="/static/aaa.png"></image>
		</view>
		<view class="flex-ju-c mt30">
			<view class="pg25 bgF3F3F3 size22 width600">
				可以回答你的问题，什么问题都可以，政策、生活、经济的都可以，你可以把问题通过输入框发给我。来开启第一个话题吧：
			</view>
			<view>
				{{content}}
			</view>
		</view>
		<view class=" width1000">
			<view class="posifi width1000  flex1 bottom0 flex-ju-b zindex50 bgfff">
				<view class="flex-ju-b flex1 pg30  mg30 ra20 bnde">
					<input v-model="msgcon" class="flex1"  placeholder="发消息...." />
					<image @click="send" src="/static/send.png" mode="widthFix" class="width52"></image>
				</view>
			</view>
		</view>
		<view class="con pb200 flex" style="flex-direction: column-reverse">
			
			<view v-for="(item,index) in arr" class="flex mt30" :style="{flexDirection:index % 2==0 ?'row-reverse':''}">
				<image class="wh100-100 ra100" src="/static/aaa.png"></image>
				<view class="mt15 mr15">
					<view style="max-width: 400rpx;" class="bgF3F3F3 ra15 pg20">{{item.title}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				content:"",
				arr:[],
				msgcon:"",
				a:0
			}
		},
		mounted() {
		 
		},
		methods: {
			send(){
				this.arr.unshift({
					title:this.msgcon,
					that:this.a++
				})
				
				return
				const requestTask = wx.request({
				    url: 'https://ark.cn-beijing.volces.com/api/v3/chat/completions',
				    data: {
				        "model": "doubao-seed-1-6-250615",
						"messages": [
						      {
						        "role": "user",
						        "content": "随便写个1个字母"
						      }
						    ],
						    "stream": true
				    },
					enableChunked:true,
					responseType: 'arraybuffer',
					method:'post',
				    header: {
						"Accept": 'text/event-stream',
				        "Content-Type":"application/json",
						"Authorization":"Bearer cf8eb38f-ea48-4c11-a925-979a0cd61ad9" 
				    },
					
				});
				
				requestTask.onChunkReceived((chunk) => {
					 const data = new TextDecoder('utf-8').decode(chunk.data);
					var aa = data.replace(/data: /g, '').trim()
					console.log(aa)
					var s = aa.split('\n')
					var arr =[]
					s.map(item=>{
						if(item.indexOf('reasoning_content')!= -1){
							this.content+=JSON.parse(item).choices[0].delta.reasoning_content
						}
					})
				});
			
			}
		}
	}
</script>

<style>
	page{
		background: #fff;
	}
	.bnde{
		box-shadow: 0rpx 6rpx 13rpx 0rpx rgba(28,48,75,0.18);
	}
</style>
